package org.blade.personal.component.listener;

import java.util.Date;

import javax.persistence.PrePersist;

import org.blade.personal.mode.BaseEntity;

public class EntityListener implements IEntityListener<BaseEntity<Long>,Long>{

	
	public void postLoad(BaseEntity<Long> entity) {
		
	}

	@PrePersist
	public void prePersist(BaseEntity<Long> entity) {
		entity.setUuid(java.util.UUID.randomUUID().toString());
		
		Date now = new Date();
		entity.setCreatedDate(now);
		entity.setModifyDate(now);
	}

	@Override
	public void postPersist(BaseEntity<Long> entity) {
		
	}

	@Override
	public void preUpdate(BaseEntity<Long> entity) {
		
		Date now = new Date();
		entity.setModifyDate(now);
	}

	@Override
	public void postUpdate(BaseEntity<Long> entity) {
		
	}

	@Override
	public void preRemove(BaseEntity<Long> entity) {
		
	}

	@Override
	public void postRemove(BaseEntity<Long> entity) {
		
	}

}
